package com.cvte.chart.ui;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.ViewTreeObserver;
import android.widget.AbsoluteLayout;
import android.widget.Button;
import android.widget.LinearLayout;

import com.cvte.chart.demo.R;
import com.cvte.chart.logic.SupportLineUtils;

import org.achartengine.GraphicalView;


public class SupportLineActivity extends Activity {
    private SupportLineUtils mLineUtils;
    private AbsoluteLayout mLinearLayoutLine;
    GraphicalView view;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_support_line);
        mLinearLayoutLine = (AbsoluteLayout) findViewById(R.id.linearLayout_line);
        mLineUtils = new SupportLineUtils(this.getApplicationContext());
        view = (GraphicalView) mLineUtils.initLineGraphView();
        mLinearLayoutLine.addView(view);
        //view重绘时回调



        view.setDrawedListener(new GraphicalView.DrawedListener() {
            @Override
            public void drawed() {
                Log.e("llll2", view.isChartDrawn() + "");
                Log.e("llll2", view.getCurrentPoint(0).getX()+ "");
                Log.e("llll2", view.getCurrentPoint(1).getX()+ "");
                Log.e("llll2", view.getCurrentPoint(2).getX()+ "");
                Log.e("llll2", view.getCurrentPoint(3).getX()+ "");
                Log.e("llll2", view.getCurrentPoint(4).getX()+ "");
                Log.e("llll2", view.getCurrentPoint(5).getX()+ "");
                Log.e("llll2", view.getCurrentPoint(6).getX()+ "");
                Log.e("llll2", view.getCurrentPoint(7).getX()+ "");
                Log.e("llll2", view.getCurrentPoint(8).getX()+ "");
                Log.e("llll2", view.getCurrentPoint(9).getX()+ "");
                Log.e("llll2", view.getCurrentPoint(10).getX()+ "");
                Log.e("llll2", view.getCurrentPoint(11).getX()+ "");
                AbsoluteLayout.LayoutParams lp=    new AbsoluteLayout.LayoutParams(50,50,(int)view.getCurrentPoint(3).getX()-25,(int)view.getCurrentPoint(3).getY()-25);
                mLinearLayoutLine.addView(new Button(SupportLineActivity.this),lp);
            }
        });







    }

    @Override
    protected void onResume() {
        super.onResume();

    }
}
